//
//  FeedbackViewController.m
//  Korea
//
//  Created by 崔剑 on 15/9/8.
//  Copyright (c) 2015年 KoreaGo. All rights reserved.
//

#import "FeedbackViewController.h"
#import "Header.h"

@interface FeedbackViewController () <UITextViewDelegate>

@property (nonatomic, strong) UILabel *feedbackLabel;
@property (nonatomic, strong) UILabel *contactLabel;
@property (nonatomic, strong) UITextView *feedbackTV;
@property (nonatomic, strong) UITextField *contactTF;
@property (nonatomic, strong) UILabel *placeHolderLabel;

@end

@implementation FeedbackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"意见反馈";
    self.view.backgroundColor = [UIColor colorWithRGB:0xf3f4f8 alpha:1];
    self.navigationController.navigationBar.translucent = NO;
    // 返回键
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back@2x.png"] style:UIBarButtonItemStylePlain target:self action:@selector(leftAction:)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];

    self.feedbackLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.view.width / 2, 40)];
    self.feedbackLabel.backgroundColor = [UIColor colorWithRGB:0xf3f4f8 alpha:1];
    self.feedbackLabel.text = @"反馈内容";
    self.feedbackLabel.textColor = [UIColor grayColor];
    self.feedbackLabel.font = [UIFont boldSystemFontOfSize:14];
    [self.view addSubview:self.feedbackLabel];
    
    self.feedbackTV = [[UITextView alloc] initWithFrame:CGRectMake(0, 40, self.view.width, 90)];
    self.feedbackTV.backgroundColor = [UIColor whiteColor];
    self.feedbackTV.delegate = self;
    self.feedbackTV.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    self.feedbackTV.font = [UIFont systemFontOfSize:17];
    self.feedbackTV.hidden = NO;
    // 进入ViewController直接打开键盘
    [self.feedbackTV becomeFirstResponder];
    [self.view addSubview:self.feedbackTV];
    
    self.placeHolderLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 40, self.view.width - 10, 40)];
    self.placeHolderLabel.text = @" 我们聆听对Ssam的任何意见或建议!";
    self.placeHolderLabel.enabled = NO;
    self.placeHolderLabel.backgroundColor = [UIColor clearColor];
    self.placeHolderLabel.textColor = [UIColor blueColor];
    [self.view addSubview:self.placeHolderLabel];
    
    
    self.contactLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 130, self.view.width / 2, 50)];
    self.contactLabel.backgroundColor = [UIColor colorWithRGB:0xf3f4f8 alpha:1];
    self.contactLabel.text = @"联系方式";
    self.contactLabel.textColor = [UIColor grayColor];
    self.contactLabel.font = [UIFont boldSystemFontOfSize:14];
    [self.view addSubview:self.contactLabel];
    
    self.contactTF = [[UITextField alloc] initWithFrame:CGRectMake(0, 180, self.view.width, 40)];
    self.contactTF.placeholder = @"  请输入手机号或邮箱 (选填)";
    self.contactTF.borderStyle = UITextBorderStyleRoundedRect;
    self.contactTF.clearButtonMode = UITextFieldViewModeAlways;
    self.contactTF.keyboardType = UIKeyboardTypeDefault;
    self.contactTF.keyboardAppearance = UIKeyboardAppearanceDefault;
    self.contactTF.returnKeyType = UIReturnKeySend;
    [self.view addSubview:self.contactTF];
    
    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];
    //设置成NO表示当前控件响应后会传播到其他控件上，默认为YES。
    tapGestureRecognizer.cancelsTouchesInView = NO;
    //将触摸事件添加到当前view
    [self.view addGestureRecognizer:tapGestureRecognizer];

    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"send@2x.png"] style:UIBarButtonItemStylePlain target:self action:@selector(sendAction:)];
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
}

- (void)textViewDidChange:(UITextView *)textView
{

    if (textView.text.length == 0) {
        self.placeHolderLabel.text = @" 我们聆听对Ssam的任何意见或建议!";
    } else {
        self.placeHolderLabel.text = @"";

    }
    
}

- (void)sendAction:(UIBarButtonItem *)sendBut
{
    
    
    
    
}


- (void)leftAction:(UIBarButtonItem *)button
{
    // 返回
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)keyboardHide:(UITapGestureRecognizer*)tap{
    [self.feedbackTV resignFirstResponder];
    [self.contactTF resignFirstResponder];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
